/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.ukni.persistence.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author eurico
 */
@Entity
@Table(name = "ACCOUNT")
@NamedQueries({@NamedQuery(name = "Account.findAll", query = "SELECT a FROM Account a"), @NamedQuery(name = "Account.findByIdaccount", query = "SELECT a FROM Account a WHERE a.idaccount = :idaccount"), @NamedQuery(name = "Account.findByUsername", query = "SELECT a FROM Account a WHERE a.username = :username"), @NamedQuery(name = "Account.findByEmail", query = "SELECT a FROM Account a WHERE a.email = :email"), @NamedQuery(name = "Account.findByPassword", query = "SELECT a FROM Account a WHERE a.password = :password"), @NamedQuery(name = "Account.findByAccounttype", query = "SELECT a FROM Account a WHERE a.accounttype = :accounttype"), @NamedQuery(name = "Account.findByDatecreation", query = "SELECT a FROM Account a WHERE a.datecreation = :datecreation")})
public class Account implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "IDACCOUNT")
    private Integer idaccount;
    @Basic(optional = false)
    @Column(name = "USERNAME")
    private String username;
    @Basic(optional = false)
    @Column(name = "EMAIL")
    private String email;
    @Basic(optional = false)
    @Column(name = "PASSWORD")
    private String password;
    @Basic(optional = false)
    @Column(name = "ACCOUNTTYPE")
    private int accounttype;
    @Basic(optional = false)
    @Column(name = "DATECREATION")
    @Temporal(TemporalType.DATE)
    private Date datecreation;
    @JoinTable(name = "FOLLOW", joinColumns = {@JoinColumn(name = "REFIDACCOUNT", referencedColumnName = "IDACCOUNT")}, inverseJoinColumns = {@JoinColumn(name = "REFIDBAND", referencedColumnName = "IDBAND")})
    @ManyToMany(fetch = FetchType.EAGER)
    private Set<Band> bandCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.EAGER)
    private Set<CommentVideo> commentVideoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.EAGER)
    private Set<CommentBand> commentBandCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.EAGER)
    private Set<CommentImage> commentImageCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.EAGER)
    private Set<Friend> friendCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account1", fetch = FetchType.EAGER)
    private Set<Friend> friendCollection1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.EAGER)
    private Set<CommentAudio> commentAudioCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.EAGER)
    private Set<CommentEvent> commentEventCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "account", fetch = FetchType.EAGER)
    private Band band;

    public Account() {
    }

    public Account(Integer idaccount) {
        this.idaccount = idaccount;
    }

    public Account(Integer idaccount, String username, String email, String password, int accounttype, Date datecreation) {
        this.idaccount = idaccount;
        this.username = username;
        this.email = email;
        this.password = password;
        this.accounttype = accounttype;
        this.datecreation = datecreation;
    }

    public Integer getIdaccount() {
        return idaccount;
    }

    public void setIdaccount(Integer idaccount) {
        this.idaccount = idaccount;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getAccounttype() {
        return accounttype;
    }

    public void setAccounttype(int accounttype) {
        this.accounttype = accounttype;
    }

    public Date getDatecreation() {
        return datecreation;
    }

    public void setDatecreation(Date datecreation) {
        this.datecreation = datecreation;
    }

    public Set<Band> getBandCollection() {
        return bandCollection;
    }

    public void setBandCollection(Set<Band> bandCollection) {
        this.bandCollection = bandCollection;
    }

    public Set<CommentVideo> getCommentVideoCollection() {
        return commentVideoCollection;
    }

    public void setCommentVideoCollection(Set<CommentVideo> commentVideoCollection) {
        this.commentVideoCollection = commentVideoCollection;
    }

    public Set<CommentBand> getCommentBandCollection() {
        return commentBandCollection;
    }

    public void setCommentBandCollection(Set<CommentBand> commentBandCollection) {
        this.commentBandCollection = commentBandCollection;
    }

    public Set<CommentImage> getCommentImageCollection() {
        return commentImageCollection;
    }

    public void setCommentImageCollection(Set<CommentImage> commentImageCollection) {
        this.commentImageCollection = commentImageCollection;
    }

    public Set<Friend> getFriendCollection() {
        return friendCollection;
    }

    public void setFriendCollection(Set<Friend> friendCollection) {
        this.friendCollection = friendCollection;
    }

    public Set<Friend> getFriendCollection1() {
        return friendCollection1;
    }

    public void setFriendCollection1(Set<Friend> friendCollection1) {
        this.friendCollection1 = friendCollection1;
    }

    public Set<CommentAudio> getCommentAudioCollection() {
        return commentAudioCollection;
    }

    public void setCommentAudioCollection(Set<CommentAudio> commentAudioCollection) {
        this.commentAudioCollection = commentAudioCollection;
    }

    public Set<CommentEvent> getCommentEventCollection() {
        return commentEventCollection;
    }

    public void setCommentEventCollection(Set<CommentEvent> commentEventCollection) {
        this.commentEventCollection = commentEventCollection;
    }

    public Band getBand() {
        return band;
    }

    public void setBand(Band band) {
        this.band = band;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idaccount != null ? idaccount.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Account)) {
            return false;
        }
        Account other = (Account) object;
        if ((this.idaccount == null && other.idaccount != null) || (this.idaccount != null && !this.idaccount.equals(other.idaccount))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "deti.es.ukni.persistence.entity.Account[idaccount=" + idaccount + "]";
    }

}
